Java EE 7 Recipes by Josh Juneau
Author:Josh Juneau
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA
7-8. Utilizing Java Objects for Database Access
Problem
Your application works with an underlying database for storing and retrieving data. You would prefer to code your business logic using Java objects, rather than working directly with JDBC and SQL for performing database activities.
Solution
Create a data access object (DAO) for each database table that will be used to perform the mundane JDBC and SQL work. Within the DAO, create façade methods that accept Java objects to represent a single record of data for the database table for which the DAO has been created. Use the Java objects to pass record data to and from the DAO, while the DAO breaks the objects apart and utilizes the data fields within standard SQL statements.
The following class excerpts demonstrate a data access object for the AUTHOR database table, which is used for storing book author data (a main method has been included merely for testing purposes within this DAO).
Note
For the full source listing, please refer to the org.javaeerecipes.chapter07.dao.AuthorDAO class, located in the JavaEERecipes NetBeans project. Repetitive portions of the sources (finally blocks) have been removed from the following listing for brevity.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Get Your Hands Dirty on Clean Architecture by Tom Hombergs(1406)
The Clojure Workshop by Joseph Fahey Thomas Haratyk Scott McCaughie Yehonathan Sharvit & Konrad Szydlo(1273)
Head First Java by Kathy Sierra(1098)
Java EE 8 Design Patterns and Best Practices by Rhuan Rocha(907)
Java EE 8 Design Patterns and Best Practices by Joao Purificacao & Rhuan Rocha(774)
Java Programming for beginners: Learn Java Development in this illustrated step by step Coding Guide by Mastery White Belt(673)
Head First Java™ by Kathy Sierra & Bert Bates(542)
Java All-in-One For Dummies (For Dummies (Computers)) by Lowe Doug(535)
Just Hibernate by Madhusudhan Konda(509)
Spring 5.0 Projects by Nilang Patel(506)
Clojure Cookbook by Luke VanderHart & Ryan Neufeld(425)
Java 8 Lambdas by Richard Warburton(424)
Java: Learn Java in One Day and Learn It Well. Java for Beginners with Hands-on Project. (Learn Coding Fast with Hands-On Project Book 4) by Chan Jamie & LCF Publishing(420)
Java Programming by Fain Yakov(378)
Head First: Android Development by Griffiths Dawn & Griffiths David(360)
Maven: The Definitive Guide by Company Sonatype(324)
Clojure Programming by Chas Emerick & Brian Carper & Christophe Grand(316)
Java Performance by Scott Oaks(313)
Data Structures and Algorithms Using Java by William McAllister(305)
